package com.dexstudio.adapters;

import java.util.ArrayList;
import java.util.HashMap;

import android.content.Context;
import android.widget.SimpleAdapter;

public class CurrencyAdapter extends SimpleAdapter {
	//constants
	public static final String CURRENCY_NAME = "CurrName";
	public static final String CURRENCY_BUY = "CurrBuy";
	public static final String CURRENCY_SALE = "CurrSale";
	//constructor
	public CurrencyAdapter(Context context,
			ArrayList<HashMap<String, String>> data, int resource,
			int[] to) {
		super(context, data, resource, 
				new String[] {CURRENCY_NAME, CURRENCY_BUY, CURRENCY_SALE}, to);
		this.data = data;
	}
	
	public void add(String currName, float currBuy, float currSale) {
		HashMap<String,String> newElement = new HashMap<String,String>();
		newElement.put(CURRENCY_NAME, currName);
		newElement.put(CURRENCY_BUY, String.valueOf(currBuy));
		newElement.put(CURRENCY_SALE, String.valueOf(currSale));
		
		this.add(newElement);
	}
	
	public void add(HashMap<String, String> newElement) {
		data.add(newElement);
		this.notifyDataSetChanged();
	}
	
	public void remove(int position) {
		data.remove(position);
		this.notifyDataSetChanged();
	}
	
	//Objects % Variables
	private ArrayList<HashMap<String, String>> data;
}